/**
 * flyiu.com Inc.
 * Copyright (c) 2018-2019 All Rights Reserved.
 */
package com.flyiu.data.consistency.integrate;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Component;

import com.flyiu.data.consistency.model.IdempotentEntity;
import com.flyiu.data.consistency.repository.IdempotentRepository;
import com.flyiu.data.idempotent.service.IdempotentService;

/** 
 * <p>
 * </p>
 *
 * @author chenjh@flyiu.com
 * @version $Id: IdempotentServiceImpl.java, v 0.1 2019年2月22日 下午2:33:56 chenjh Exp $
 */
//@ConditionalOnMissingBean
@Component
public class IdempotentServiceImpl implements IdempotentService<IdempotentEntity> {
    
    /** 默认幂等性属性保存Mapper */
    @Autowired
    private IdempotentRepository idempotentRepository;


    /** 
     * @see com.flyiu.data.idempotent.service.IdempotentService#findAllByBusinessId(java.lang.String)
     */
    @Override
    public List<IdempotentEntity> findAllByBusinessId(String businessId) {
        return idempotentRepository.findAll( (root,query,cb) ->cb.equal( root.get("bussinessId"), businessId),new Sort(Direction.ASC, "id"));
    }

}
